Skip to main content

All Questions

4votes
4answers
1kviews

Check if a binary tree is symmetric in Python

I have solved the following Leetcode problem. Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric....
user82261's user avatar
1vote
1answer
203views

Maximum Width binary tree

Here is my code for the LeetCode problem For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
MrJoe's user avatar
  • 2,133
8votes
2answers
2kviews

Word-Ladder solver in Python 3

Follow-up to Python program to find a word ladder transforming "four" to "five" I'm trying to write a program to solve a word ladder puzzle to brush up on my Python. For those who ...
Alex F's user avatar
1vote
1answer
487views

Python program for Word Search II

This is a Leetcode problem - Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of a sequentially adjacent ...
Justin's user avatar
  • 2,585
-4votes
1answer
94views

Finding the sublist with best utility function among all list's permutations [closed]

I try to find the the better solution in terms of time complexity. Among the list of elements I need to find the sublist with maximum value of given utility function. Each element has it's own type. ...
Daniel Chepenko's user avatar
2votes
1answer
2kviews

Given a binary tree, find the maximum path sum

This is a leetcode.com problem. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path must ...
Stack crashed's user avatar
1vote
1answer
2kviews

Generating and finding parent nodes in a post-order tree

Given a height h and list q of integers, list the parent node of each element in q, if nodes are read in post-order sequence ...
Jake Steele's user avatar
6votes
2answers
957views

HackerRank Binary search tree validation

From here: ...
enderland's user avatar
3votes
1answer
2kviews

"The Story of a Tree" solved using depth-first search

Found this problem in hackerrank. One day Bob drew a tree, with \$n\$ nodes and \$n-1\$ edges on a piece of paper. He soon discovered that parent of a node depends on the root of the tree. The ...
newbie_old's user avatar
4votes
1answer
174views

Counting increasing subsequences with a "hacker's" Binary Index Tree

This is an \$O(n \sqrt n)\$ solution to the the following problem: Given a sequence, compute the number of non-empty increasing subsequences The algorithm is to compute ...
Elliot Gorokhovsky's user avatar
3votes
1answer
1kviews

Request for memory optimizations for solution to Google FooBar challenge, "ion_flux_relabeling,"

I just finished one of the Google FooBar Challenges.My Python is super rusty. I did the challenge in Haskell first and then attempted to covert the code. I am guessing that led to some bad Python ...
LambdaScientist's user avatar
15votes
5answers
9kviews

Google Foobar Challenge: Lucky Triples

Note: Since my time has passed for this challenge, I do not remember exactly the stipulations but will attempt to recapitulate them to the best of my knowledge. Essentially, the challenge was this: ...
Edwin Rice's user avatar
6votes
2answers
660views

"File Fix-it" challenge

I'm learning Python and have found this problem from Google Code Jam: How many mkdir commands does it take to construct a given directory tree: Input The first ...
gkr's user avatar
  • 63

close